﻿@model ProductModel.ProductCategoryModel

@{
    var parentModel = ViewData["Parent"] as ProductModel;
}
@*TODO: (mc) (core) data grid produces script error "Cannot read property 'settings' of undefined" in jquery.validate.js when clicking row selection checkbox*@
<datagrid id="productcategories-grid" class="h-100"
          allow-resize="true"
          allow-row-selection="true"
          allow-edit="true">
    <datasource read="@Url.Action("ProductCategoryList", new { productId = parentModel.Id })"
                delete="@Url.Action("ProductCategoryDelete")"
                update="@Url.Action("ProductCategoryUpdate")"
                insert="@Url.Action("ProductCategoryInsert", new { productId = parentModel.Id })" />
    <paging position="Bottom" page-index="1" show-size-chooser="false" />
    <toolbar>
        <toolbar-group>
            <button datagrid-action="DataGridToolAction.InsertRow" type="button" class="btn btn-primary btn-flat no-anims mr-auto">
                <i class="fa fa-plus"></i>
                <span>@T("Admin.Common.AddNew")</span>
            </button>
            <button datagrid-action="DataGridToolAction.SaveChanges" type="button" class="btn btn-warning no-anims btn-flat">
                <i class="fa fa-check"></i>
                <span>@T("Admin.Common.SaveChanges")</span>
            </button>
            <button datagrid-action="DataGridToolAction.CancelEdit" type="button" class="btn btn-light btn-flat mr-auto">
                <span>@T("Common.Cancel")</span>
            </button>
        </toolbar-group>
        <zone name="datagrid_toolbar_alpha"></zone>
        <toolbar-group class="omega"></toolbar-group>
        <zone name="datagrid_toolbar_omega"></zone>
        <toolbar-group>
            <button datagrid-action="DataGridToolAction.DeleteSelectedRows" type="button" class="btn btn-danger no-anims btn-flat">
                <i class="far fa-trash-alt"></i>
                <span>@T("Admin.Common.Delete.Selected")</span>
            </button>
        </toolbar-group>
    </toolbar>
    <columns>
        <column for="CategoryId" hideable="false" width="4fr" entity-member="Category.Name">
            <display-template>
                <a :href="item.row.EditUrl" class="text-truncate" v-html="item.row.Category"></a>
            </display-template>
        </column>
        <column for="IsFeaturedProduct" halign="center" />
        <column for="DisplayOrder" halign="center" />
        <column for="IsSystemMapping" halign="center" readonly />
    </columns>
    <row-commands>
        <a datarow-action="DataRowAction.InlineEdit">@T("Common.Edit")</a>
        <a datarow-action="DataRowAction.Delete">@T("Common.Delete")</a>
    </row-commands>
</datagrid>